import pika

# # RabbitMQ连接参数
# rabbitmq_host = '10.16.152.203'
# rabbitmq_port = 5672
# rabbitmq_username = 'test'
# rabbitmq_password = 'Un9Q4Jxw^D8f'
#
# # 创建连接
# credentials = pika.PlainCredentials(rabbitmq_username, rabbitmq_password)
# connection = pika.BlockingConnection(pika.ConnectionParameters(host=rabbitmq_host, port=rabbitmq_port, credentials=credentials))
#
# # 创建通道
# channel = connection.channel()
#
# # 打印连接成功信息
# print("连接RabbitMQ成功")
#
#
#
# # 关闭连接
# connection.close()


def conn_rabbitmq():
    # RabbitMQ连接参数
    rabbitmq_host = '10.16.152.203'
    rabbitmq_port = 5672
    rabbitmq_username = 'test'
    rabbitmq_password = 'Un9Q4Jxw^D8f'
    credentials = pika.PlainCredentials(rabbitmq_username, rabbitmq_password)
    connection = pika.BlockingConnection(pika.ConnectionParameters(host=rabbitmq_host, port=rabbitmq_port, credentials=credentials))
    channel = connection.channel()
    print("连接RabbitMQ成功")
    return connection, channel

# 11.65.197.144:5672
def conn_rabbitmq_guian():
    # RabbitMQ连接参数
    rabbitmq_host = '11.65.197.144'
    rabbitmq_port = 5672
    rabbitmq_username = 'test'
    rabbitmq_password = 'Un9Q4Jxw^D8f'
    credentials = pika.PlainCredentials(rabbitmq_username, rabbitmq_password)
    connection = pika.BlockingConnection(
        pika.ConnectionParameters(host=rabbitmq_host, port=rabbitmq_port, credentials=credentials))
    channel = connection.channel()
    print("连接RabbitMQ成功")
    return connection, channel
